package com.dljd.javase.t12.example1;

public class PriorityDemo {
    public static void main(String[] args) {
        Thread  t2=new Thread("B"){
            public void run() {
                for (int i = 0; i <10 ; i++) {
                    try {
                        Thread.sleep(500);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println(this.getName()+"-"+i);
                }
            }
        };
        t2.setPriority(Thread.NORM_PRIORITY);
        t2.start();


        Thread  t3=new Thread("C"){
            public void run() {
                for (int i = 0; i <10 ; i++) {
                    try {
                        Thread.sleep(500);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println(this.getName()+"-"+i);
                }
            }
        };
        t3.setPriority(Thread.MAX_PRIORITY);
        t3.start();

        Thread  t1=new Thread("A"){
            public void run() {
                for (int i = 0; i <10 ; i++) {
                    Thread.yield();
                    try {
                        Thread.sleep(500);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println(this.getName()+"-"+i);
                }
            }
        };
        t1.setPriority(Thread.MIN_PRIORITY);
        t1.start();

    }
}
